//
//  OneViewController.swift
//  DemoUI
//
//  Created by 白瑾浩 on 2022/1/8.
//

import UIKit
class OneViewController: UIViewController,TwoViewControllerProtocol {
    
    //协议的方法实现
    func sendData(cardId: String, sex: String, name: String) {
        print( "我是TwoViewController传递过来的值：\(cardId),\(sex),\(name)" )
    }
    

    override func viewDidLoad() {
        super.viewDidLoad()
        self.view.backgroundColor = .white
        // Do any additional setup after loading the view.
        let button14 = UIButton(type: UIButton.ButtonType.system)
        button14.frame = CGRect(x: 10, y: 200, width: 200, height: 30)
        button14.setTitle("去第二个页面", for: UIControl.State.normal)
        button14.addTarget(self, action: #selector(JumpTwoViewControl), for: .touchUpInside)
        self.view.addSubview( button14 )
    }
    @objc func JumpTwoViewControl(){
        let mTwoViewController = TwoViewController(sex:"男",name:"codeceo")
        //设置属性值
        mTwoViewController?.cardId = "111111"
        mTwoViewController?.delegate  = self
        //闭包传递过来的
        mTwoViewController?.closure = {(cardId:String) in
            print( "我是TwoViewController传递过来的值：\(cardId)" )
        }
        if( mTwoViewController !== nil ){
            self.present(mTwoViewController!, animated: true, completion: nil)
        }

    }
}
